
// composition API模式

import { ref, computed, reactive } from 'vue'
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', () => {
  // const success = ref(false)
  const count = ref(5)
  const doubleCount = computed(() => count.value * 2)
  function increment() {
    count.value++
  }
// 底部内容
  const footerTitle = reactive({})
  const computedFooterTitle = computed((e) => footerTitle.value  = e)
  function incrementFooterTitle() {
    footerTitle.value+1
  }
  // 用户信息
  const userNamePass = reactive({})
  const userNamePassdata = computed((e) => userNamePass.value  = e)
  function incrementuserNamePassdata() {
    console.log(userNamePass);
  }



  return {
    count, doubleCount, increment,
    footerTitle, computedFooterTitle, incrementFooterTitle,
    userNamePass, userNamePassdata, incrementuserNamePassdata
  }
}
, {
  persist: true// 整个store都会被持久化
})
